<template>
  <div>

    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>系统中心</el-breadcrumb-item>
      <el-breadcrumb-item>借贷管理</el-breadcrumb-item>
      <el-breadcrumb-item>标的上架</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
    <el-row>
      <el-form :model="userForm" label-width="70px">
        <el-col :span="5">
          <el-form-item label="姓名">
            <el-input placeholder="借款方" v-model="userForm.fullName"></el-input>
          </el-form-item>
        </el-col>
      </el-form>
      <el-button type="info" plain @click="search()">搜索</el-button>
<!--      <el-button type="primary" @click="centerDialogVisible = true">添加用户</el-button>-->
    </el-row>
    <el-table
      :data="biaolist"
      style="width: 100%">
      <el-table-column
        align="center"
        type="index"
        label="编号"
        width="80px">
      </el-table-column>
      <el-table-column
        align="center"
        prop="fullName"
        label="借款人"
        width="120">
      </el-table-column>
      <el-table-column
        align="center"
        prop="tel"
        label="借款人手机"
        width="120">
      </el-table-column>
      <el-table-column
        align="center"
        prop="bidName"
        label="标名"
        width="120">
      </el-table-column>
      <el-table-column
        align="center"
        prop="egname"
        label="担保机构"
        width="120">
      </el-table-column>
      <el-table-column
        align="center"
        prop="loanType"
        label="类型"
        width="120">
        <template slot-scope="scope">
          {{scope.row.loanType|loanTypeFit}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="totalAmount"
        label="借款金额"
        width="120">
      </el-table-column>
      <el-table-column
        align="center"
        prop="interest"
        label="年化利率"
        width="120">
        <template slot-scope="scope">
          {{scope.row.interest}}%
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="repayType"
        label="还款方式"
        width="120">
        <template slot-scope="scope">
          {{scope.row.repayType|repayTypeFit}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="trem"
        label="期限"
        width="120">
        <template slot-scope="scope">
          {{scope.row.trem}}{{scope.row.termType|tremTypeFit}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="createTime"
        label="审核时间"
        width="150">
        <template slot-scope="scope">
          {{scope.row.createTime | datefmt('YYYY-MM-DD HH:mm:ss')}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="status"
        label="状态">
        <template slot-scope="scope">
          {{scope.row.status | statusFit}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="操作">
        <template slot-scope="scope">
          <el-dropdown size="mini" split-button type="primary" trigger="click">
            操作
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item v-if="scope.row.status==0" @click.native="update(scope.row.id,1)">发布</el-dropdown-item>
              <el-dropdown-item @click.native="toLook(scope.row.id)">查看</el-dropdown-item>
              <el-dropdown-item @click.native="toUpdate(scope.row.id)">修改</el-dropdown-item>
              <el-dropdown-item @click.native="toDeleteById(scope.row.id)" style="background-color: #ff0000">删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      align="center"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.pagenum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="page.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </el-card>
  </div>
</template>
<script>
  export default {
    name: "borrowuser",
    data(){
      return{
        biaolist:[],
        AddScore:{},
        ScoredialogFormVisible:false,
        page:{
          pagenum:0,
          pagesize:5
        },
        status:'1',
        isShow:false,
        total:0,
        fullName:'',
        userid:'',
        rolelist:[],
        roleIds:{},
        centerDialogVisible:false,
        userDialogVisible:false,
        importExcelVisible:false,
        auth:{token:''},
        userForm:{},
        BorrowerId:null,
      }
    },
    methods:{
      toDeleteById:function(id){
        this.$http.post("/finance-service-borrowing/ebankbidinfo/DeleteById/"+id).then((res)=>{
          if(res.data.success){
            this.$message({
              message:res.data.message,
              type: 'success'
            });
            this.search();
          }else{
            this.$message.error(res.data.message);
          }
          }
        )
      },
      toUpdate:function(id){
        this.$router.push("/updatebid?id="+id);
      },
      toLook:function(id){
        /**/
        this.$router.push("/tolookbiao?id="+id);
      },
      handleSizeChange:function (val) {
        this.page.pagesize=val;
        this.search();
      },
      handleCurrentChange:function (val) {
        this.page.pagenum=val;
        this.search();
      },
      search:function () {
        this.$http.post("/finance-service-borrowing/ebankbidinfo/getListAll/"+this.page.pagenum+"/"+this.page.pagesize,this.userForm).then(
          (res)=>{
            this.biaolist=res.data.result.list;
            this.total=res.data.result.total;
          }
        )
      },
      update:function (id,status) {
          this.$http.post("/finance-service-borrowing/ebankbidinfo/updateStatus/"+id+"/"+status).then((res)=>{
            if(res.data.success){
              this.$message({
                message:res.data.message,
                type: 'success'
              });
              5
            }else{
              this.$message.error(res.data.message);
            }
            this.search();
          })
      }
    },
    filters:{
      statusFit:function (val) {
        if (val==0){
          return "未发标";
        }
        if (val==1){
          return "募集中"
        }
        if (val==2){
          return "撤标"
        }
        if (val==4){
          return "满标"
        }
      },
      loanTypeFit:function (val) {
        if (val==0){
          return "新增";
        }
        if (val==1){
          return "续贷";
        }
        if (val==2){
          return "资产处理";
        }
      },
      repayTypeFit:function (val) {
        if (val==0){
          return "一次性还款";
        }
        if (val==1){
          return "等额本金";
        }
        if (val==2){
          return "等额本息";
        }
      },
      tremTypeFit:function (val) {
        if (val==0){
          return "天";
        }
        if (val==1){
          return "月";
        }
      }
    },
    mounted() {
      this.search();
      this.auth.token=sessionStorage.getItem("token");
    }
  }
</script>

<style scoped>

</style>
